package com.doudou.commons.validate;

import lombok.extern.slf4j.Slf4j;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Collection;

/**
 * @program:
 * @description
 * @author: 傻男人
 * @create: 2019-10-08 09:26
 **/
@Slf4j
public class ListNotEmptyHandler implements ConstraintValidator<ListNotEmpty,Object> {

    @Override
    public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
        if(null == object){
            return false;
        }
        Collection array = (Collection) object;
        if(array == null || array.isEmpty()){
            return false;
        }
        return true;
    }
}
